#include "FSM.h"



 FSM::FSM() {
    std::cout<<"开始工作..."<<std::endl;
}



void FSM::setBuf_token(std::string token) {
    char c[16];
    for(int i=0;i<16;i++){
        c[i]=token[i];
    }
    buf_token=c;
}

char* FSM::getBuf_token() {
    return buf_token;
}

void* FSM::run(void* arg) {
    int i=1;
    char buf_token_[16];
    while(1){
        switch (i) {
            case 1:
            {
                cout<<"开始"<<endl;
                startup();
                ifstream file_token_temp;
                file_token_temp.open("temp_to_token.txt");
                file_token_temp>>buf_token_;
                FSM::setBuf_token(buf_token_);
                file_token_temp.close();
            }
                break;
            case 2:
            {
                cout<<"延时十秒"<<endl;
                // set();
                sleep(10);

            }
                break;
            case 3:
            {
                cout<<"运行"<<endl;
                collect_data();
            }
                break;
            case 4:{
                cout<<"再见"<<endl;
                ifstream file_token_temp;
                file_token_temp.open("temp_to_token.txt");
                file_token_temp>>buf_token;
                file_token_temp.close();
                goodbye(buf_token);
            }
            case 5:{
                //file_clear();
            }
                break;
        }
        i++;
        if(i>5)
            i=1;
    }
}